using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;

namespace BlogKickStart.Models.Mapping
{
    public class UserMap : EntityTypeConfiguration<User>
    {
        public UserMap()
        {
            // Primary Key
            this.HasKey(t => t.UserID);

            // Properties
            this.Property(t => t.FirstNM)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.LastNM)
                .IsRequired()
                .HasMaxLength(100);

            this.Property(t => t.Pass)
                .HasMaxLength(100);

            this.Property(t => t.UserName)
                .IsRequired()
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("Users");
            this.Property(t => t.UserID).HasColumnName("UserID");
            this.Property(t => t.FirstNM).HasColumnName("FirstNM");
            this.Property(t => t.LastNM).HasColumnName("LastNM");
            this.Property(t => t.Birthday).HasColumnName("Birthday");
            this.Property(t => t.CreateDate).HasColumnName("CreateDate");
            this.Property(t => t.BlogID).HasColumnName("BlogID");
            this.Property(t => t.Pass).HasColumnName("Pass");
            this.Property(t => t.UserName).HasColumnName("UserName");

            // Relationships
			//this.HasRequired(t => t.Blog)
			//    .WithMany(t => t.Users)
			//    .HasForeignKey(d => d.BlogID);

        }
    }
}
